package strategy

import (
	"github.com/gogf/gf/container/garray"
	"github.com/gogf/gf/util/gconv"
)

type Random struct {
	*Strategy
}

func (s *Random) New(strategy *Strategy) (Channel, error) {
	return &Random{
		Strategy: strategy,
	}, nil
}

func (s *Random) Apply(gateways []string) []string {
	return gconv.Strings(garray.NewFrom(gconv.SliceAny(gateways)).Shuffle().PopRands(len(gateways)))
}
